﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
using NetMicro.Core.Extensions;

namespace NetMicro.Domains.Extensions
{
    public static class EntityBaseExtensions
    {
        public static Expression<Func<TEntity, TEntity>> EntityBaseUpdateCombine<TEntity, TKey>(this Expression<Func<TEntity, TEntity>> columns)
            where TEntity : EntityBase<TKey>, new()
        {
            TEntity entity = new TEntity();
            entity.UpdateInit(entity);
            Expression<Func<TEntity, TEntity>> columns1 = m => new TEntity
            {
                IsDeleted = entity.IsDeleted,
                Version = entity.Version,
                UpdateId = entity.UpdateId,
                UpdateName = entity.UpdateName,
                UpdateTime = entity.UpdateTime
            };
            return columns1.Combine(columns);
        }
    }
}
